package com.sdkj.Entity.admin;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.sdkj.Entity.BaseEntity;

/**
 * 管理员用户
 * @author admin
 *
 */
@Entity
@Table(name="admin_user")
public class AdminUser extends BaseEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String account;
	private String pwd;
	private String portrait;//头像
	private String birthday;//生日
	private int sex;
	private int level;//
	private String remark;
	
	private List<AdminModule> modules=new ArrayList<AdminModule>();
	private List<AdminPrivs> privs=new ArrayList<AdminPrivs>();
	
	@Column(length=30)
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	@Column(length=36)
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	@Column(length=50)
	public String getPortrait() {
		return portrait;
	}
	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}
	@Column(length=20)
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	@Column(length=10)
	public int getSex() {
		return sex;
	}
	public void setSex(int sex) {
		this.sex = sex;
	}
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name = "admin_user_modules", joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "uuid") }, inverseJoinColumns = { @JoinColumn(name = "module_id", referencedColumnName = "uuid") })
	public List<AdminModule> getModules() {
		return modules;
	}
	public void setModules(List<AdminModule> modules) {
		this.modules = modules;
	}
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name = "admin_user_privs", joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "uuid") }, inverseJoinColumns = { @JoinColumn(name = "priv_id", referencedColumnName = "uuid") })
	public List<AdminPrivs> getPrivs() {
		return privs;
	}
	public void setPrivs(List<AdminPrivs> privs) {
		this.privs = privs;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
}
